package com.ryan.demo.grpc.client.service;


import com.ryan.demo.grpc.api.AckReceiptData;
import com.ryan.demo.grpc.api.SendAckData;
import com.ryan.demo.grpc.api.SubAckHubGrpc;
import io.grpc.Deadline;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;


/**
 * @author MRyan
 */
@Service
public class SendAckGrpcService {

    @Resource(name = "subAckHubBlockingStub")
    private SubAckHubGrpc.SubAckHubBlockingStub subAckHubBlockingStub;

    public AckReceiptData sendAck(SendAckData sendAckData) {
        return subAckHubBlockingStub
                .withDeadline(Deadline.after(5, TimeUnit.SECONDS))
                .sendAck(sendAckData);
    }
}
